
<template>
  <div>
    <el-tree-select
        :data="administrativeOptions"
        :props="{ value: 'administrativeId', label: 'administrativeName', children: 'children' }"
        value-key="administrativeId"
        placeholder="请选择父级"
        check-strictly
    />
  </div>
</template>
<script lang="ts" setup>
import {getCurrentInstance, onMounted, ref} from 'vue'
import { listAdministrative } from "@/api/system/administrative";
const { proxy } = getCurrentInstance()
const administrativeOptions = ref([])
const getlistAdministrative = () => {
  listAdministrative().then(response => {
    administrativeOptions.value = []
    const data = { administrativeId: 0, administrativeName: '顶级节点', children: [] }
    data.children = proxy.handleTree(response.data, "administrativeId", "parentId")
    administrativeOptions.value.push(data)
  })
};
onMounted(()=>{
  getlistAdministrative();
})
</script>